
*******************************************************************************
****						Appendix Table G20 - REGRESSION OF TOTAL TOLL *****
****	ON TIME DIFFERENTIALS: I-210W AS A SUBSTITUTE					*******
*******************************************************************************
use ".\data\clean\raw5mindata_I210.dta", clear
keep if type=="ML"
keep if dir=="W"
keep speed date hour min
collapse speed, by(date hour min)
ren speed unlagged210speed
merge 1:m date hour min using ".\data\clean\reg_data_covars_031915_v2.dta", nogen keep(2 3)
drop if weekend==1 | dow==0 | dow==6
* Travel time difference is versus 210
gen TT_dif_hr210=max(dist/unlagged210speed-dist/ELspeed,0)
capture est sto clear
la var reliability_diff "Reliability"
la var TT_dif_hr210 "Travel Time I-210W"
replace reliability_diff=0 if reliability_diff<=0.01
reg charged_toll TT_dif_hr210 reliability_diff if inlist(hour,5,6,7,8), cluster(rt_id)
estimates store a1






use ".\data\clean\reg_data_covars_031915_v2.dta", clear
drop if weekend==1 | dow==0 | dow==6
g reliability_diffnew=max(reliability_diff,0.01)
replace reliability_diff=reliability_diffnew if reliability_diff!=. 
capture drop period
g period=cond( inlist(hour,5,6,7,8),1,cond(inlist(hour,16,17,18,19),2,cond(inlist(hour,9,10,11,12,13,14,15),3,4)))
label def period 1 "AM Peak" 2 "PM Peak" 3 "Mid-Day Off-Peak" 4 "Eve. Off-Peak"
la var TT_dif_hr "Travel Time"
la var reliability_diff "Reliability"

* High and low 210 speeds
egen avg210=mean(lnspeed210), by(hour dow)
g above210=cond(lnspeed210>avg210,1,0)
xi: reg charged_toll TT_dif_hr reliability_diff if inlist(hour,5,6,7,8) & above210==0, cluster(rt_id)
estimates store a2
xi: reg charged_toll TT_dif_hr reliability_diff if inlist(hour,5,6,7,8) & above210==1, cluster(rt_id)
estimates store a3
esttab  a1 a2 a3 using ".\results\appendix\tabs\ATC8.csv", replace  ///
	cells(b(star fmt(%9.3f)) se(par)) star(* 0.10 ** 0.05 *** 0.01) stats(r2 N,fmt(%9.3f %9.0g) labels(R-squared N)) ///
	addnotes("Excludes weekends holidays imputed observations and observations where travel time is negative. Reliab. Diff. set at zero when HOV reliability is worse. Below Avg. are observations where the average hourly speed on the I-210W for the preceeding hour is at or below its average for that hour and day of week. Above Avg. is when it lies above the average.") ///
	title("Table C.8--REGRESSION OF TOTAL TOLL ON TIME DIFFERENTIALS: I-210 Speeds") ///
	mtitles("Whole Sample" "Below Avg." "Above Avg." ) nonumbers nodepvars ///
	 order(_cons TT_dif_hr210 TT_dif_hr reliability_diff) label
	

insheet using ".\results\appendix\tabs\ATG20.csv", comma clear
export excel using ".\results\appendix\AppendixFigsTabs.xlsx", ///
	sheet("Appendix Table G20", replace) 	

putexcel set ".\results\appendix\AppendixFigsTabs.xlsx", sheet("Appendix Table G20") modify
putexcel A6="Travel Time I-210W"
